package com.libgdxbar.pvzlikegame.objects;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Disposable;
import com.libgdxbar.pvzlikegame.AssetsLoader;
import com.libgdxbar.pvzlikegame.entities.LocationEntity;
import org.libgdxbar.projects.interfaces.renderer.IBatchRender;

public class TextureSplashLogo extends LocationEntity implements IBatchRender, Disposable {
	private final Texture texture = AssetsLoader.getInstance().get("libgdx.png", Texture.class);
	private Vector2 texSize = new Vector2();
	private Vector2 size = new Vector2();
	private Vector2 scl = new Vector2(1, 1);

	public TextureSplashLogo() {
		this(0, 0);
	}

	public TextureSplashLogo(float x, float y) {
		setPosition(x, y);
		texSize.set(texture.getWidth(), texture.getHeight());
	}

	@Override
	public void render(Batch batch) {
		Vector2 position = getPosition();
		batch.draw(texture, position.x, position.y, getSize().x, getSize().y);
	}

	@Override
	public void dispose() {
	}

	public void setScl(float sclX, float sclY) {
		scl.set(sclX, sclY);
	}

	public Vector2 getSize() {
		return size.set(texSize.x * scl.x, texSize.y * scl.y);
	}

	public void setCenterPosition(float cx, float cy) {
		Vector2 size = getSize();
		setPosition(cx - size.x / 2, cy - size.y / 2);
	}
}
